package com.eazykitchen.util;

import org.springframework.http.ResponseEntity;

public class BaseResponse<T> {

    private int responseCode;
    private String responseMsg;
    private T data;
    public BaseResponse(int responseCode, String responseMsg, T data) {
        this.responseCode = responseCode;
        this.responseMsg = responseMsg;
        this.data = data;
    }

    //请求成功(带成功信息和数据)
    public static ResponseEntity generateOKResponseEntity(String responseMsg, Object object) {
    // Map<String, Object> obj = new HashMap<String, Object>();
        return ResponseEntity.ok().body(new BaseResponse<>(0, responseMsg, object));
    }

    //请求成功(带数据)
    public static ResponseEntity generateOKResponseEntity(Object object) {
        return ResponseEntity.ok().body(new BaseResponse<>(0, "Success", object));
    }

    public static ResponseEntity generateBadResponseEntity(int code, String message, Object object) {
        return ResponseEntity.ok().body(new BaseResponse<>(code, message, object));
    }

    public int getResponseCode() {
        return responseCode;
    }

    public void setResponseCode(int responseCode) {
        this.responseCode = responseCode;
    }

    public String getResponseMsg() {
        return responseMsg;
    }

    public void setResponseMsg(String responseMsg) {
        this.responseMsg = responseMsg;
    }

    public T getData() {
        return data;
    }

}
